home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 050a.dms / 050a.adf / TEXTS / chapter20.txt < prev    next >
Text File  |  1992-02-26  |  7KB  |  255 lines

  1.                      The Absolute Beginners Guide To Amos
  2.                     -------------------------------------
  3.                                 Chapter Twenty
  4.                                 --------------
  5. We are now going to take a look at a few more mouse commands and take our
  6. first look at the joystick commands offered by Amos.
  7.  
  8. LIMIT MOUSE x1,y1 TO x2,y2
  9. --------------------------
  10. This command LIMITs the MOUSE pointer to any area of the screen This can be
  11. useful, if for example,  you have a control panel on screen and you don't
  12. want the user to click anywhere outside the panel.  
  13. As you would expect x1,y1 are the coordinates for the top left hand corner 
  14. of the box and x2,y2 is the bottom right hand corner of the box area to be 
  15. LIMITed. The coordinates for this command must be in hardware coordinates 
  16. these are different to screen coordinates. Here is an alternative way to 
  17. LIMIT the MOUSE using the normal screen coordinates:
  18.  
  19. LIMIT MOUSE XHARD(X1),YHARD(Y1) TO XHARD(X2),YHARD(Y2)
  20. -----------------------------------------------------
  21. What we are doing is asking Amos to convert the screen coordinates into
  22. hardware coordinates for us, a lot easier.  
  23.  
  24. The LIMIT MOUSE command used on it`s own with no coordinates supplied will 
  25. restore the mouse pointer to it`s original full screen limit.
  26.  
  27.  
  28. X MOUSE
  29. -------
  30. Y MOUSE
  31. -------
  32. Returns the value of the X or Y mouse positions in hardware coordinates.
  33. See EXAMPLE20.Amos for an ample demonstration of these commands.
  34.  
  35.                 ------------------------------------
  36.  
  37. Now let us take a look at the joystick commands:
  38.  
  39. FIRE (port number)
  40. ------------------
  41. This command tests if the FIRE button has been pressed.  
  42. FIRE must be followed by the port number to be tested in brackets:
  43.  
  44. X=FIRE(1)
  45.  
  46. The port on the right hand side of your Amiga (mouse port) is port 0 and the
  47. normal joystick port (left side) is port 1.
  48. The value returned in X will be -1 (minus one) if the fire button has been
  49. pressed otherwise it will be 0. So a typical line in a game could be:
  50.  
  51. IF FIRE(1) then SHOOT
  52.  
  53. We do not need the -1 in the above line as -1 stands for true and the THEN
  54. part of the statement will only be executed if the IF part is true.
  55. If the IF part was false (0) then the THEN part will be ignored.
  56. remember the (1) is the port number.
  57.  
  58. The rest of these joystick commands work exactly the same:
  59.  
  60. X=JLEFT (port number)
  61.  
  62. X=JRIGHT (port number) 
  63.  
  64. X=JUP (port number)
  65.  
  66. X=JDOWN (port number)
  67.  
  68.               ----------------------------------- 
  69.  
  70. The following are the latest commands we have looked at and a brief 
  71. description of each.
  72.  
  73.  
  74. BAR            Draw a filled rectangle
  75.  
  76. BOX            Draw a hollow rectangle
  77.  
  78. CIRCLE         Draw a circle 
  79.  
  80. CHIP FREE      Returns amount of free Chip memory left
  81.  
  82. DFREE          Returns available bytes left on current disk
  83.  
  84. DIR$           Change current directory
  85.  
  86. DIM            Dimension an array
  87.  
  88. DRAW           Draw a straight line
  89.  
  90. END PROC       This must be the last instruction of every procedure
  91.  
  92. EXIST          Enquire if a file or disk exists
  93.  
  94. FAST FREE      Returns amount of FAST memory available for use
  95.  
  96. FIRE           Test if the joystick FIRE button has been pressed
  97.  
  98. FREE           Returns available space left in variable buffer
  99.  
  100. GLOBAL         Sets defined variables to be used inside and outside of procs
  101.  
  102. JDOWN          Test for joystick down
  103.  
  104. JLEFT          Test for joystick left
  105.  
  106. JRIGHT         Test for joystick right
  107.  
  108. JUP            Test for joystick up
  109.  
  110. KILL           Delete a file permanently
  111.  
  112. LDIR           Lists a directory of the current disk to the printer
  113.  
  114. LIMIT MOUSE    LIMIT the MOUSE pointer to a defined rectangle of the screen
  115.  
  116. LLIST         *Lists a basic program to the printer
  117.  
  118. LPRINT         Print a string of text to the printer 
  119.  
  120. MKDIR          Create a folder or drawer on the current disk
  121.  
  122. PLOT           Plot a pixel of colour onto the screen
  123.  
  124. PROCEDURE      Create a procedure 
  125.  
  126. POP PROC       Abort a procedure before it`s natural end
  127.  
  128. READ           Used to read data statements, usually for DIMensioned arrays
  129.  
  130. RENAME         Rename a file
  131.  
  132. SORT           Sort a dimensioned array in alpha or numerical order
  133.  
  134. XGR            Returns the X value of graphics cursors current position
  135.  
  136. XHARD          Converts screen to hardware coordinates
  137.  
  138. XMOUSE         Returns the X value of the mouse pointer in hardware coords
  139.  
  140. YGR            Returns the Y value of graphics cursors current position
  141.  
  142. YHARD          Converts screen coordinates to hardware coordinates
  143.  
  144. YMOUSE         Returns the Y value of the mouse pointer in hardware coords
  145.  
  146. *LList does not work on the original Amos package. If you want to print your
  147. program listing to the printer select it as a block and use PRINT BLOCK from
  148. the menus at the top of the screen.
  149. ----------------------------------------------------------------------------
  150.  
  151.                  And here is the last self test quiz horray!
  152.                  ============================================
  153.  
  154. Q 1. What does the command BAR achieve?
  155.  
  156.   a) Draws a filled rectangle
  157.   b) Draws a hollow rectangle
  158.   c) Draws a triangle
  159.  
  160.  
  161. Q 2. Which command would you use to delete a file from a disk?
  162.  
  163.   a) Delete
  164.   b) DIR$
  165.   c) Kill
  166.  
  167.  
  168. Q 3. Who is the odd man out?
  169.  
  170.   a) DIM
  171.   b) Read
  172.   c) Plot
  173.  
  174.  
  175. Q 4. What would the following line achieve?
  176.      
  177.      MKDIR "DF0: KILL"
  178.  
  179.   a) Creates a drawer on DF0:
  180.   b) Deletes all the files on DF0:
  181.   c) Installs the disk in DF0:
  182.  
  183.  
  184. Q 5. How would you break out of a procedure before the END PROC command?
  185.  
  186.   a) GOSUB
  187.   b) GOTO
  188.   c) POP PROC  
  189.  
  190.  
  191. Q 6.  What does the last parameter (c) in PLOT x,y,c stand for?              
  192.  
  193.   a) Clear
  194.   b) Colour
  195.   c) Cls
  196.  
  197.  
  198. Q 7.  What do the XGR and YGR commands achieve?
  199.  
  200.   a) Return the graphics cursors current coordinates
  201.   b) Return the text cursors current coordinates
  202.   c) return the disk drives warp speed
  203.  
  204.  
  205. Q 8.  What is wrong with the following?
  206.  
  207.       DRAW 100,10
  208.  
  209.   a) There are two parameters missing
  210.   b) The syntax is correct
  211.   c) There is one parameter missing.
  212.  
  213.  
  214. Q 9. Who is the odd man out?
  215.  
  216.   a) PROCEDURE
  217.   b) POP PROC
  218.   c) EXIST 
  219.  
  220.  
  221. Q10. What does the SORT command achieve?
  222.  
  223.   a) Sorts a dimensioned array into order
  224.   b) Sorts memory chunks into slices
  225.   c) Sorts out your personal life
  226.  
  227.               -----------------------------------
  228.  
  229. This seems as good a time as any to have a quick look at key press commands.
  230.  
  231. We are familiar with WAIT KEY and CLEAR KEY but what if we want to know the
  232. exact key that was pressed by the user, from a menu of options maybe.
  233. The following is a piece of code I have used many many times in my basic
  234. programs over the years. Make a note, as I am sure you will use it too.
  235.  
  236. CLEAR KEY: K$="": WHILE K$="": K$=INKEY$: WEND
  237.  
  238. This line will CLEAR the KEYboard buffer of any previous key presses and
  239. start looping between WHILE and WEND until a key is pressed, when this 
  240. happens the loop will be broken and K$ will contain the key that was pressed.
  241.  
  242. Your next lines could read something like this:
  243.  
  244. IF K$="1" THEN DOSOMETHING
  245. IF K$="Q" THEN QUITGAME
  246.  
  247. etc.
  248.  
  249. There are lots of different ways of achieving the same result but I prefer
  250. this as it`s simple and effective.
  251.  
  252.  
  253.                               End of Chapter 20
  254.                               ^^^^^^^^^^^^^^^^^
  255.